package com.fan.client;

import com.google.common.collect.Lists;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;

public class DefaultConfig implements PropertyConfig {
    private List<ConfigChangeListener> listeners = Lists.newCopyOnWriteArrayList();
    private Map<String, String> property = new ConcurrentHashMap<>();
    private Map<String, Object> beanProperty = new ConcurrentHashMap<>();
    private String profile = "";
    private String configUrl = "";
    private String appName = "";

    @Override
    public String getProperty(String key) {
        return this.property.get(key);
    }

    @Override
    public void addChangeListener(ConfigChangeListener listener) {
        this.listeners.add(listener);
    }

    @Override
    public Set<String> getPropertyNames() {
        return property.keySet();
    }

    @Override
    public void setProperty(String key, String value) {
        property.put(key, value);
    }

    @Override
    public Map<String, Object> getBeanProperty() {
        return beanProperty;
    }

    @Override
    public String getProfile() {
        return profile;
    }

    @Override
    public void setProfile(String profile) {
        this.profile = profile;
    }

    @Override
    public String getConfigUrl() {
        return configUrl;
    }

    @Override
    public void setConfigUrl(String configUrl) {
        this.configUrl = configUrl;
    }

    @Override
    public String getAppName() {
        return appName;
    }

    @Override
    public void setAppName(String appName) {
        this.appName = appName;
    }
}
